from typing import List


class Solution:
    def maxSubArray(self, nums: List[int]) -> int:
        if(len(nums) == None):
            return 0
        res = nums[0]
        n = 0
        for i in nums:
            if(n < 0):
                n = i
            else:
                n = n+i
            res = max(n, res)

        return res


if __name__ == "__main__":
    print(Solution().maxSubArray([-2, 1, -3, 4, -1, 2, 1, -5, 4]))
